package com.chen.web;

import com.chen.web.domain.User;
import com.netflix.hystrix.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

import java.time.temporal.Temporal;

/**
 * @decription
 * @atuhor:陈红卫
 * @create : 2017-06-17-17:28
 */

public class UserCommand extends HystrixCommand<User> {

    @Autowired
    private RestTemplate restTemplate;

    private Long id;

    public UserCommand(Setter setter , RestTemplate restTemplate, long id) {
        super(setter);

        this.restTemplate= restTemplate;
        this.id=id;
    }

    @Override
    protected User run() throws Exception {
        return restTemplate.getForObject("http://USER-SERVICE//getUserById?id={1}",User.class,id);
    }
}
